package com.shu.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Service
public class UserService implements InitializingBean, BeanNameAware, BeanFactoryAware {

    private String userName;

    public UserService() {
        System.out.println(">>>> UserService");
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println(">>>> postConstruct");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println(">>>> preDestroy");
    }

    public void init() {
        System.out.println(">>>> init");
    }

    public void destory() {
        System.out.println(">>>> destory");
    }

    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println(">>>> setBeanFactory");
    }

    public void setBeanName(String s) {
        System.out.println(">>>> setBeanName");
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println(">>>> afterPropertiesSet");
    }
}